package org.dtrd.modules.record.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.record.entity.bean.SigninBodyDetail;


/**
 * <p>
 * 人体成分分析表
 * </p>
 *
 * @author sun
 * @since 2022-08-08
 */
@Getter
@Setter
@TableName("dtrd_ent_rd_signin_body")
public class DtrdEntRdSigninBody {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    /**
     * 患者id
     */
    @TableField("patient_id")
    private Integer patientId;

    /**
     * 记录日期  yyyy-MM-dd
     */
    @TableField("record_date")
    private String recordDate;

    /**
     * 记录时间 yyyy-MM-dd HH:mm:ss
     */
    @TableField("record_time")
    private Date recordTime;

    /**
     * 人体成分分析图
     */
    @TableField("record_photo")
    private String recordPhoto;

    /**
     * 身高
     */
    @TableField("height")
    private String height;

    /**
     * 体重
     */
    @TableField("weight")
    private String weight;

    /**
     * 肌肉
     */
    @TableField("muscle")
    private String muscle;

    /**
     * 骨骼肌
     */
    @TableField("skeletal_muscle")
    private String skeletalMuscle;

    /**
     * 骨质
     */
    @TableField("bone")
    private String bone;

    /**
     * BMI
     */
    @TableField("bmi")
    private String bmi;

    /**
     * 腰臀比
     */
    @TableField("whr")
    private String whr;

    /**
     * 蛋白质
     */
    @TableField("protein")
    private String protein;

    /**
     * 脂肪
     */
    @TableField("fat")
    private String fat;

    /**
     * 体脂
     */
    @TableField("body_fat")
    private String bodyFat;

    /**
     * 无机盐
     */
    @TableField("inorganic_salt")
    private String inorganicSalt;

    /**
     * 基础代谢
     */
    @TableField("bmr")
    private String bmr;

    public DtrdEntRdSigninBody init() {
        createTime = new Date();
        isDel = 0;
        return this;
    }

    public DtrdEntRdSigninBody parseFromDto(SigninBodyDetail dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        if (dto.getRecordTime() != null) {
            recordTime = dto.getRecordTime();
            recordDate = DateUtils.formatDate(dto.getRecordTime(), DateUtils.date_sdf.get().toPattern());
        }
        recordPhoto = dto.getRecordPhoto();
        height = dto.getHeight();
        weight = dto.getWeight();
        muscle = dto.getMuscle();
        skeletalMuscle = dto.getSkeletalMuscle();
        bone = dto.getBone();
        bmi = dto.getBmi();
        whr = dto.getWhr();
        protein = dto.getProtein();
        fat = dto.getFat();
        bodyFat = dto.getBodyFat();
        inorganicSalt = dto.getInorganicSalt();
        bmr = dto.getBmr();
        return this;
    }


}
